package com.bml.architect.proivder.service;

import com.bml.architect.DemoService;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.config.annotation.Service;
import org.apache.dubbo.rpc.RpcContext;

@Service(version = "ld",loadbalance = "roundrobin")
public class LoadBalanceServiceImpl implements DemoService {
    @Override
    public String sayHello(String name) {
        System.out.println("执行了负载均衡的服务 "+ name);

        URL url = RpcContext.getContext().getUrl();
        return String.format("%s:%s,hello,%s",url.getProtocol(),url.getPort(),name);
   }

    @Override
    public String sayHello1(String name) {

        URL url = RpcContext.getContext().getUrl();
        return String.format("%s:%s,hello,%s",url.getProtocol(),url.getPort(),name);
    }
}
